home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Warrior’s Progress / source code / Source / Libraries / Memory / Pools / FinitePoolBase.h < prev   
Encoding:
Text File  |  1997-06-28  |  784 b   |  39 lines  |  [TEXT/CWIE]

  1. // FinitePoolBase.h
  2.  
  3. #ifndef FinitePoolBase_h
  4. #define FinitePoolBase_h
  5.  
  6. #ifndef BitArrayBase_h
  7. #include "BitArrayBase.h"
  8. #endif
  9.  
  10. class FinitePoolBase
  11.   {
  12.     private:
  13.         uint8 *const space;
  14.         BitArrayBase& map;
  15.         const uint32 elementSize;
  16.         uint32 allocated;
  17.         uint32 nextAllocation;
  18.         
  19.         // not implemented:
  20.             FinitePoolBase( const FinitePoolBase& );
  21.             void operator=( const FinitePoolBase& );
  22.         
  23.     public:
  24.         FinitePoolBase( void *theSpace,
  25.                              BitArrayBase& theMap,
  26.                              uint32 elementSize );
  27.         
  28.         bool Full() const            { return allocated < map.Length(); }
  29.         bool IsEmpty() const        { return allocated == 0; }
  30.  
  31.         void *Allocate( uint32 size );
  32.         void Release( void * );
  33.   };
  34.  
  35. inline void *operator new( uint32 size, FinitePoolBase& pool )
  36.     { return pool.Allocate( size ); }
  37.  
  38. #endif
  39.